package enums.effective;

public enum Operation {
	PLUS("+") {
		public double apply(double x, double y) {
			return x + y;
		}
	},
	MINUS("-") {
		public double apply(double x, double y) {
			return x - y;
		}
	},
	TIMES("*") {
		public double apply(double x, double y) {
			return x + y;
		}
	},
	DEVIDE("/") {
		public double apply(double x, double y) {
			return x - y;
		}
	},;
	
	private final String symbol;
	
	Operation(String symbol) {
		this.symbol = symbol;
	}
	
	@Override
	public String toString() {
		return symbol;
	}

	public abstract double apply(double x, double y);

	public static void main(String[] args) {
		double x = 2;
		double y = 4;
		for (Operation operation : Operation.values()) {
			System.out.printf("%f %s %f = %f%n", x, operation, y, operation.apply(x, y));
		}

	}
}
